﻿@using tour.szhome.common;
@{
    ViewBag.Title = "项目相册";
}
<h3>项目相册</h3>
<div style="padding-left:50px;">
        <hr />
        <table class="tb">
            <tr>
                <td colspan="2" bgcolor="#FFFFFF">
                    <a href="/manage/project">项目列表&gt;&gt; </a>
                    <span id="lblXMMC" style="color:Red;">@ViewBag.Name </span>图片上传的说明: 
                    <span style="color: Gray;">只允许上传的JPG,GIF格式图片, 每个文件大小不可超过1Mb.</span>              
                    <br>
                </td>
            </tr>
        </table>
        <hr />
        <table class="tb" style="padding:5px;width:99%;">
            <tbody>
                <tr>
                    <td align="center" width="100"><span>实景图：</span></td>
                    <td>
                        <input type="file" name="upload" id="upload1" />
                        <br />
                        <ul style="list-style:none;float:left">
                            @foreach (var item in ViewBag.sList)
                            {
                                <li id="@item.XCID" style="float:left;margin:5px;">
                                    <img name="Img" src="/uploadfiles/big/@item.SLTLJ" style="height:100px;width:100px;border-width:0px;" />
                                    <a href="javascript:del_project(@item.XCID)">删除</a>
                                </li>
                            }
                        </ul> 
                    </td>
                </tr>
                <tr>
                    <td align="center"><span>效果图：</span></td>
                    <td>
                        <input type="file" name="upload" id="upload2" />
                        <br />
                        <ul style="list-style:none;float:left">
                            @foreach (var item in ViewBag.xList)
                            {
                                <li id="@item.XCID" style="float:left;margin:5px;">
                                    <img name="Img" src="/uploadfiles/big/@item.SLTLJ" style="height:100px;width:100px;border-width:0px;" />
                                    <a href="javascript:del_project(@item.XCID)">删除</a>
                                </li>
                            }
                        </ul> 
                    </td>
                </tr>
                <tr>
                    <td align="center"><span>规划图：</span></td>
                    <td>
                        <input type="file" name="upload" id="upload3" />
                        <br />
                        <ul style="list-style:none;float:left">
                            @foreach (var item in ViewBag.gList)
                            {
                                <li id="@item.XCID" style="float:left;margin:5px;">
                                    <img name="Img" src="/uploadfiles/big/@item.SLTLJ" style="height:100px;width:100px;border-width:0px;" />
                                    <a href="javascript:del_project(@item.XCID)">删除</a>
                                </li>
                            }
                        </ul>
                    </td>
                </tr>
                <tr>
                    <td align="center"><span>配套图：</span></td>
                    <td>
                        <input type="file" name="upload" id="upload4" />
                        <br />
                        <ul style="list-style:none;float:left">
                            @foreach (var item in ViewBag.pList)
                            {
                                <li id="@item.XCID" style="float:left;margin:5px;">
                                    <img name="Img" src="/uploadfiles/big/@item.SLTLJ" style="height:100px;width:100px;border-width:0px;" />
                                    <a href="javascript:del_project(@item.XCID)">删除</a>
                                </li>
                            }
                        </ul>
                    </td>
                </tr>
                <tr>
                    <td align="center"><span>活动图：</span></td>
                    <td>
                        <input type="file" name="upload" id="upload5" />
                        <br />
                        <ul style="list-style:none;float:left">
                            @foreach (var item in ViewBag.hList)
                            {
                                <li id="@item.XCID" style="float:left;margin:5px;">
                                    <img name="Img" src="/uploadfiles/big/@item.SLTLJ" style="height:100px;width:100px;border-width:0px;" />
                                    <a href="javascript:del_project(@item.XCID)">删除</a>
                                </li>
                            }
                        </ul>
                    </td>
                </tr>
            </tbody>
        </table>
    <hr />
</div>
@CommPath.StyleImport("public/plug-in/uploadify/uploadify.css")
@CommPath.ScriptImport("public/plug-in/uploadify/jquery.uploadify-3.2.js")
<script type="text/javascript">
    
    $(function(){
        // 这里暂时不知道怎么处理好，先一个个监听吧
        $('#upload1').uploadify({
            'buttonText': '选择文件',
            'buttonClass': 'browser',
            'width': 90,
            'height': 25,
            'formData' : {'f':"@ViewBag.Folder"},
            'fileTypeExts': '*.jpg;*.png;*.bmp;*.gif;',
            'swf': '@CommPath.FileImport("public/plug-in/uploadify/uploadify.swf")',
            'uploader': '/manage/help/UploadFiles',
            'onUploadSuccess': function (file, data, response) {
                edit(0,data);
            },
            'onSelectError': function (file, errorCode, errorMsg) {
                switch (errorCode) {

                    case -110:
                        alert("文件 [" + file.name + "] 大小超出系统限制的" + (1024 * 1024 * 5) + "大小！");
                        break;
                    case -120:
                        alert("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        alert("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            }
        });

        // 这里暂时不知道怎么处理好，先一个个监听吧
        $('#upload2').uploadify({
            'buttonText': '选择文件',
            'buttonClass': 'browser',
            'width': 90,
            'height': 25,
            'formData' : {'f':"@ViewBag.Folder"},
            'fileTypeExts': '*.jpg;*.png;*.bmp;*.gif;',
            'swf': '@CommPath.FileImport("public/plug-in/uploadify/uploadify.swf")',
            'uploader': '/manage/help/UploadFiles',
            'onUploadSuccess': function (file, data, response) {
                edit(1,data);
            },
            'onSelectError': function (file, errorCode, errorMsg) {
                switch (errorCode) {

                    case -110:
                        alert("文件 [" + file.name + "] 大小超出系统限制的" + (1024 * 1024 * 5) + "大小！");
                        break;
                    case -120:
                        alert("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        alert("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            }
        });

        // 这里暂时不知道怎么处理好，先一个个监听吧
        $('#upload3').uploadify({
            'buttonText': '选择文件',
            'buttonClass': 'browser',
            'width': 90,
            'height': 25,
            'formData' : {'f':"@ViewBag.Folder"},
            'fileTypeExts': '*.jpg;*.png;*.bmp;*.gif;',
            'swf': '@CommPath.FileImport("public/plug-in/uploadify/uploadify.swf")',
            'uploader': '/manage/help/UploadFiles',
            'onUploadSuccess': function (file, data, response) {
                edit(2,data);
            },
            'onSelectError': function (file, errorCode, errorMsg) {
                switch (errorCode) {

                    case -110:
                        alert("文件 [" + file.name + "] 大小超出系统限制的" + (1024 * 1024 * 5) + "大小！");
                        break;
                    case -120:
                        alert("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        alert("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            }
        });

        // 这里暂时不知道怎么处理好，先一个个监听吧
        $('#upload4').uploadify({
            'buttonText': '选择文件',
            'buttonClass': 'browser',
            'width': 90,
            'height': 25,
            'formData' : {'f':"@ViewBag.Folder"},
            'fileTypeExts': '*.jpg;*.png;*.bmp;*.gif;',
            'swf': '@CommPath.FileImport("public/plug-in/uploadify/uploadify.swf")',
            'uploader': '/manage/help/UploadFiles',
            'onUploadSuccess': function (file, data, response) {
                edit(3,data);
            },
            'onSelectError': function (file, errorCode, errorMsg) {
                switch (errorCode) {

                    case -110:
                        alert("文件 [" + file.name + "] 大小超出系统限制的" + (1024 * 1024 * 5) + "大小！");
                        break;
                    case -120:
                        alert("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        alert("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            }
        });

        // 这里暂时不知道怎么处理好，先一个个监听吧
        $('#upload5').uploadify({
            'buttonText': '选择文件',
            'buttonClass': 'browser',
            'width': 90,
            'height': 25,
            'formData' : {'f':"@ViewBag.Folder"},
            'fileTypeExts': '*.jpg;*.png;*.bmp;*.gif;',
            'swf': '@CommPath.FileImport("public/plug-in/uploadify/uploadify.swf")',
            'uploader': '/manage/help/UploadFiles',
            'onUploadSuccess': function (file, data, response) {
                edit(4,data);
            },
            'onSelectError': function (file, errorCode, errorMsg) {
                switch (errorCode) {

                    case -110:
                        alert("文件 [" + file.name + "] 大小超出系统限制的" + (1024 * 1024 * 5) + "大小！");
                        break;
                    case -120:
                        alert("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        alert("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            }
        });
    });

    function edit(type,img) {
        $.ajax({
            type: "post",
            url: "/manage/projectimg/json_edit",
            data: {
                XCID: 0,
                XMID: @ViewBag.ID,
                TPLX: type,
                TPLJ: img,
                SLTLJ: img
            },
            dataType: "json",
            timeout: 30000, //over time：30s
            beforeSend: function () {
                window.top.qibu.msgbox.loading("正在入库，请稍后... ...");
            },
            success: function (data) {
                window.top.qibu.msgbox.hide();
                if (data) {
                    dlg.Msg.Inf("操作成功");
                    setTimeout("window.location.href=window.location.href", 1000);
                }
                else {
                    dlg.Msg.Err("操作失败");
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                window.top.qibu.msgbox.hide();
                dlg.Msg.Err(errorThrown);
            }
        });
    }

    //delete
    function del_project(xid) {
        dlg.Confirm('提示', '确定要删除该项吗 ?', function () {
            $.getJSON("/projectimg/json_delete", { xid: xid }, function (data) {
                if (data) {
                    dlg.Msg.Cor("操作成功");
                    setTimeout("$('#' + " + xid + ").remove();", 500);
                }
                else {
                    dlg.Msg.Err("操作失败");
                }
            });
        });
    }
</script>
